/*
 * =====================================================================================
 *
 *       Filename:  main.cpp
 *
 *    Description:  this is a app to test MySerial class
 *
 *        Version:  1.0
 *        Created:  2012年04月09日 11时37分33秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Michael lee
 *        Company:
 *
 * =====================================================================================
 */
#include "MySerial.h"

int main()
{
    unsigned char buf[10]="hello";
    unsigned char rcvBuf[10];
	memset(rcvBuf,0,sizeof(rcvBuf));
    MySerial serial;
    int fd=serial.openPort(1);
    int nWrite=0;
    if(fd>0)
    {
        if(0==serial.setOpt(9600,8,'N',1))
        {
            while(1)
            {
                int nWrite=serial.writeData(buf,sizeof(buf));
                if(nWrite>0)
                {
					usleep(300000);
                    int nread=serial.readData(rcvBuf,sizeof(rcvBuf),2000);
					if(nread>0)
                    {
                        printf("recv %d %s\n",nread,rcvBuf);
                        memset(rcvBuf,0,sizeof(rcvBuf));
                    }
                }
            }
        }
    }
    return 0;
}
